const Publish = {
    //事件队列
    queue :{},
    //发送
    emit(event,data){
        //取出待触发对列
        let events = this.queue[event]
        if (events) {
            events.forEach((item) => {
                item(data)
            })
        }
    },
    //接收
    on(event,fn){
        //防止重复添加对列
        if (!this.queue[event]) {
            this.queue[event] = []
        }
        this.queue[event].push(fn)
    }
}

export default Publish